import java.util.Date;

public class Undergraduate extends Student implements Manageable {
    private double aver;

    public Undergraduate() {
    }

    public Undergraduate(String name, char gender, Date birthDay, String school, String stuId, String category, double[] score, boolean status) {
        super(name, gender, birthDay, school, stuId, category, score, status);
    }

    @Override
    public double computeAverage() throws Exception {
        double sum = 0;
        for (double score : this.score) {
            if (score < 0 || score > 100) {
                throw new UndergraduateException("成绩不在0-100范围内: " + score);
            }
            sum += score;
        }
        aver = sum / score.length;
        return aver;
    }

    @Override
    public boolean getPass() {
        return aver >= 60;
    }

    @Override
    public void printInfo() {
        System.out.println("姓名: " + name);
        System.out.println("性别: " + gender);
        System.out.println("出生日期: " + birthDay);
        System.out.println("学校: " + school);
        System.out.println("学号: " + stuId);
        System.out.println("类别: " + category);
        System.out.print("成绩: ");
        for (double s : score) {
            System.out.print(s + " ");
        }
        System.out.println("\n学位授予状态: " + (status ? "已授予学士学位" : "未授予学士学位"));
    }

    @Override
    public String getDegree() {
        return status ? "学士学位" : "未满足学位授予条件";
    }
}
